package com.jlpay.openapi.demo.clearing.withdraw;

import com.jlpay.open.jlpay.sdk.java.model.withdraw.SettleType;
import com.jlpay.open.jlpay.sdk.java.model.withdraw.request.WithdrawApplyReq;
import com.jlpay.open.jlpay.sdk.java.model.withdraw.response.WithdrawApplyResp;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author zhaomeixia
 * @since 2024/2/20
 */
public class WithdrawApplyService {

    private static final Logger LOGGER = LoggerFactory.getLogger(WithdrawApplyService.class);

    public static void main(String[] args) {
        WithdrawApplyReq withdrawApplyReq = buildWithdrawApplyRequest();
        // 发送请求
        WithdrawApplyResp withdrawApplyResp = JlpayOpenApiService.clearingService()
                .post(withdrawApplyReq, WithdrawApplyResp.class);
        LOGGER.info("提现申请响应:{}", withdrawApplyResp);
    }

    private static WithdrawApplyReq buildWithdrawApplyRequest() {
        // 商户号：849584358120016  TO结算
        // 商户号：849584358120018  T1结算
        return WithdrawApplyReq.builder()
                .merchNo("849584358120016")
                .orgNo("123456")
                .amount("10")
                .settleType(SettleType.T0)
                .outSettleId("1234567890128")
                .notifyUrl("https://www.baidu.com")
                .postscript("附言")
                .build();
    }
}
